package mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import pojo.Record;

import java.sql.Timestamp;

public interface RecordMapper {
    @Select("SELECT * FROM record WHERE floor_name=#{floor_name} AND number=#{number} AND reserve_time=#{reserve_time}")
    Record query(@Param("floor_name") String floor_name,
                 @Param("number") int number,
                 @Param("reserve_time") String reserve_time);

    @Select("CALL reserve(#{id},#{floor_name},#{number})")
    Timestamp reserve(@Param("id") String id,
                      @Param("floor_name") String floor_name,
                      @Param("number") int number);

    @Update("CALL cancel_reservation(#{floor_name},#{number},#{reserve_time})")
    void cancelReservation(@Param("floor_name") String floor_name,
                           @Param("number") int number,
                           @Param("reserve_time") String reserve_time);

    @Select("CALL start_using(#{floor_name},#{number},#{reserve_time})")
    Timestamp startUsing(@Param("floor_name") String floor_name,
                         @Param("number") int number,
                         @Param("reserve_time") String reserve_time);

    @Select("CALL end_using(#{floor_name},#{number},#{reserve_time})")
    Timestamp endUsing(@Param("floor_name") String floor_name,
                       @Param("number") int number,
                       @Param("reserve_time") String reserve_time);
}
